using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using PhysicsObjects;

using UnitLibrary.GameObjects;


namespace UnitLibrary.Managers
{
   /// <summary>
   /// Manager to handle all the objects on a given map
   /// 
   /// </summary>
    public class MapM : Manager, IManager
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="game"></param>
        /// <param name="gameScreen"></param>
        /// <param name="worldWidth"></param>
        /// <param name="worldHeight"></param>
        /// <param name="numberofCapturePoints"></param>
        public MapM(Game game, ComponentM gameComponents, float worldWidth, float worldHeight, int numberofCapturePoints)
            : base(game, gameComponents)
        {
            _worldHeight = worldHeight;
            _worldWidth = worldWidth;
            //_capturePoints = new CapturePointManager(numberofCapturePoints);
        }

       

        /// <summary>
        /// World border to map
        /// </summary>
        private Border _worldBorder;

        /// <summary>
        /// The total width of the whole world
        /// </summary>
        private float _worldWidth;

        /// <summary>
        /// The total height of the whole world
        /// </summary>
        private float _worldHeight;       

        /// <summary>
        /// An array to hold all the capture points on this map
        /// </summary>
        private CapturePoint _capturePoints;

        /// <summary>
        /// Get the width of this map
        /// </summary>
        public float WorldWidth
        {
            get { return _worldWidth; }
        }      

        /// <summary>
        /// Get the height of this map
        /// </summary>
        public  float WorldHeight
        {
            get { return _worldHeight; }
        }

        /// <summary>
        /// The back ground texture used to make this map
        /// </summary>
        private Texture2D backGroundTexture;

        /// <summary>
        /// Load the map
        /// </summary>
       public void LoadContent()
        {
            //Create the world border
            _worldBorder = new Border((int)_worldWidth, (int)_worldHeight, 75, new Vector2(_worldWidth / 2, _worldHeight / 2));
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public void Update(GameTime gameTime)
        {
            
        }

        /// <summary>
        /// Draw the map and respected components
        /// </summary>
        /// <param name="gameTime"></param>
       public void Draw(SpriteBatch _spriteBatch)
        {
            bool doneDrawing = false;
            Vector2 location = Vector2.Zero;
           
            //_worldBorder.Draw(_spriteBatch);
            
        }

        /// <summary>
        /// Compute a random safe spot on the world map
        /// </summary>
        /// <returns></returns>
        public Vector2 RandomSafeSpot()
        {
            Random rnd = new Random();
            Vector2 vector;
            vector.X = rnd.Next(25, (int)_worldWidth - 25);
            vector.Y = rnd.Next(25, (int)_worldHeight - 25);
            return vector;
        }

    }
}